package com.example.beatbox.model

import com.nhaarman.mockitokotlin2.verify
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.MatcherAssert.assertThat
import org.junit.Before
import org.junit.Test
import org.mockito.Mockito.mock


class SoundViewModelTest {

    lateinit var mBeatBox: BeatBox
    lateinit var mSound: Sound
    lateinit var mSubject: SoundViewModel

    @Before
    fun setUp() {
        mBeatBox = mock(BeatBox::class.java)
        mSound = Sound("assetPath")
        mSubject = SoundViewModel(mBeatBox)
        mSubject.sound = mSound
    }

    @Test
    fun exposesSoundNameAsTitle() {
        assertThat(mSubject.title, `is`(mSound.name))
    }

    @Test
    fun callsBeatBoxPlayOnButtonClicked() {
        mSubject.onButtonClicked()
        verify(mBeatBox).play(sound = mSound)
    }
}